<template>
  <div class="box">
    <el-row>
      <el-col :span="20">
        <div class="header">
          <el-form ref="form" :model="form" label-width="80px" class="flex">
            <el-form-item label="运单号" style="margin-left: 10px">
              <el-input
                v-model="form.name"
                placeholder="请输入运单号"
                style="width: 286px"
              ></el-input>
            </el-form-item>
            <el-form-item label="创建时间" style="margin-left: 10px">
              <el-date-picker
                v-model="value1"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>

            <el-form-item label="任务类型" style="margin-left: 10px">
              <el-select placeholder="请选择活动区域" style="width: 286px">
                <el-option label="客户" value="客户"></el-option>
                <el-option label="承包区" value="承包区"></el-option>
                <el-option label="业务员" value="业务员"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="search">查询</el-button>
              <el-button @click="clear">重置</el-button>
            </el-form-item>
            <el-form-item label="任务类型" style="margin-left: 10px">
              <el-select placeholder="请选择活动区域" style="width: 286px">
                <el-option label="客户" value="客户"></el-option>
                <el-option label="承包区" value="承包区"></el-option>
                <el-option label="业务员" value="业务员"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="任务类型" style="margin-left: 10px">
              <el-select placeholder="请选择活动区域" style="width: 286px">
                <el-option label="客户" value="客户"></el-option>
                <el-option label="承包区" value="承包区"></el-option>
                <el-option label="业务员" value="业务员"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="任务类型" style="margin-left: 10px">
              <el-select placeholder="请选择活动区域" style="width: 286px">
                <el-option label="客户" value="客户"></el-option>
                <el-option label="承包区" value="承包区"></el-option>
                <el-option label="业务员" value="业务员"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="任务类型" style="margin-left: 10px">
              <el-select placeholder="请选择活动区域" style="width: 286px">
                <el-option label="客户" value="客户"></el-option>
                <el-option label="承包区" value="承包区"></el-option>
                <el-option label="业务员" value="业务员"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
    </el-row>
    <el-row type="flex" justify="space-between">
      <el-col :span="20" class="flex">
        <div style="margin-right: 20px">快捷筛选</div>
        <div @click="tab" class="btn">
          <button id="1" :class="id === '1' ? 'active' : ''" class="title">
            全部(1895)
          </button>
          <button id="2" :class="id === '2' ? 'active' : ''" class="title">
            待认领(1)
          </button>
          <button id="3" :class="id === '3' ? 'active' : ''" class="title">
            总部介入中(0)
          </button>
          <button id="4" :class="id === '4' ? 'active' : ''" class="title">
            处理中(18)
          </button>
          <button id="5" :class="id === '5' ? 'active' : ''" class="title">
            已完结(18)
          </button>
        </div>
      </el-col>
    </el-row>
    <el-row type="flex" justify="space-between">
      <el-col :span="20" class="flex">
        <div style="margin-right: 20px">已选择0/1971条</div>
        <div @click="tab">
          <el-button plain>批量分配</el-button>
          <el-button plain>批量转交网点</el-button>
          <el-button plain>批量回复</el-button>
          <el-button plain>批量收藏</el-button>
        </div>
      </el-col>
    </el-row>
    <el-row type="flex" justify="space-between">
      <el-col :span="20">
        <el-table
          :cell-style="{ textAlign: 'center' }"
          :header-cell-style="{ textAlign: 'center' }"
          :data="tableData"
          border
          style="width: 100%"
        >
          <el-table-column
            prop="networkName.networkName"
            label="所属网点"
            width="240"
          >
          </el-table-column>
          <el-table-column prop="name" label="名称" width="120">
          </el-table-column>
          <el-table-column prop="status" label="状态" width="300">
            <template slot-scope="scope">
              {{ scope.row.status == 1 ? "正常" : "禁止" }}
            </template>
          </el-table-column>

          <el-table-column
            prop="pullUniformObject"
            label="拉均对象"
            width="120"
          >
          </el-table-column>
          <el-table-column
            prop="pullUniformDimensionality"
            label="拉均维度"
            width="120"
          >
          </el-table-column>
          <el-table-column prop="weightSection" label="重量段(kg)" width="120">
          </el-table-column>
          <el-table-column prop="excludedProvince" label="排除省份" width="120">
          </el-table-column>
          <el-table-column prop="transportType" label="运输方式" width="120">
          </el-table-column>
          <el-table-column prop="createBy" label="创建人" width="120">
          </el-table-column>
          <el-table-column prop="createTime" label="创建时间" width="120">
          </el-table-column>
          <el-table-column prop="updateBy" label="修改人" width="120">
          </el-table-column>
          <el-table-column prop="updateTime" label="修改时间" width="120">
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="500">
            <template slot-scope="scope">
              <el-button type="text" size="small">查看客户</el-button>
              <el-button type="text" size="small">个性化计泡</el-button>
              <el-button type="text" size="small">个性化结算重量</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <el-row type="flex" justify="space-between">
      <el-col :span="20">
        <div class="block" style="display: flex; justify-content: end">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  getOutletsList,
  getpullEvenList,
  pullEvenSearch,
} from "@/api/dashboard";

export default {
  data() {
    return {
      id: 1,
      form: {
        networkNameId: "",
        pullUniformObject: "",
        name: "",
      },
      //网点列表
      networkList: [],
      pages: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
      currentPage4: 4,
      tableData: [],
    };
  },
  created() {
    this.getList();
    this.getOutLet();
  },
  methods: {
    // 获取网点列表
    getOutLet() {
      getOutletsList().then((res) => {
        if (res.code == 200) {
          this.networkList = res.data;
        }
      });
    },
    tab(e) {
      if (e.target.id) {
        this.id = e.target.id;
      }
    },
    // 显示表格数据
    getList() {
      getpullEvenList().then((res) => {
        if (res.code == 200) {
          this.tableData = res.data.data;
          this.total = res.data.total;
          this.pages = res.data.pages;
        } else {
          this.$message({
            message: res.msg,
            type: "warning",
          });
        }
      });
    },
    // 查询
    search() {
      pullEvenSearch(this.form).then((res) => {
        if (res.code == 200) {
          this.tableData = res.data.data;
          this.total = res.data.total;
          this.pages = res.data.pages;
        } else {
          this.$message({
            message: res.msg,
            type: "warning",
          });
        }
      });
    },
    // 重置
    clear() {
      this.form = {};
    },
    handleSizeChange(val) {
      this.pages.pageSize = val;
      this.getList();

      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.pages.pageNum = val;
      this.getList();
      console.log(`当前页: ${val}`);
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  padding: 20px;
  display: flex;
  flex-flow: column;
}

.flex {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.header {
  padding-bottom: 20px;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}
.btn {
  width: 800px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  button {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}
.title {
  width: 150px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  font-size: 16px;
  font-family: Source Han Sans CN;
  color: #333333;
  border: 4px #f5f5f5 solid;
  background: #f5f5f5;
  margin: 20px 0;
  text-align: center;
}
.active {
  color: #2087d0;
  margin: 20px 0;
  background: #e7f3fb;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
